< previous page page_451 next page >

Page 451
12181-0451a.gif
Figure 16.3.
Creating a demo application to test the error-handling concepts.
For this example, we will be using the code in Listing 16.1 that you created in the FileCopy project earlier in this book. You may notice that the code has been simplified to enable us to concentrate on the error handler.
LISTING 16.1. FILECOPY.TXTA SUBSET OF THE FILE COPY CODE FROM CHAPTER 1.

8694cbadb9b1ef7075903f6f95fc1db2.gif
 1: Private Sub cmdCopy_Click()
 2: Dim lngFileSize As Long
 3: Dim intLoopCtr As Integer
 4: Dim intBufferCount As Integer
 5: Dim strInByte As String * 256
 6:
 7: ' If the destination file exists, ask the user if they
 8: ' want to continue
 9:     If Dir(txtTargetFile.Text) <>  Then
10:         If MsgBox(txtTargetFile.Text & vbCrLf & _
11:              already exists. Copy over old file?, vbOKCancel) =
vbCancel Then
12:             Exit Sub
13:         End If
14:     End If
15:
16: ' Get the size of the file to copy
17: ' and calculate the number of times to loop

 
< previous page page_451 next page >

If you like this book, buy it!